package com.platform.service.impl;

import com.platform.annotation.SysLog;
import com.platform.common.ServerResponse;
import com.platform.dao.EnumMapper;
import com.platform.pojo.Enum;
import com.platform.service.IEnumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 枚举服务层
 */
@Service("iEnumService")
public class EnumServiceImpl implements IEnumService {

    @Autowired
    private EnumMapper enumMapper;

    /**
     * 根据类型查询
     * @param paramMap
     * @return
     */
    @SysLog("枚举查询")
    public ServerResponse<List<Map>> selectByParam(Map paramMap){

        List<Map> enumList = enumMapper.selectEnumByPamam(paramMap);
        if(null != enumList && 0 < enumList.size()){
            return ServerResponse.createBySuccess("查询成功",enumList);
        }
        return ServerResponse.createByErrorMessage("查询失败");
    }


    @SysLog("新增枚举")
    public ServerResponse<String> insert(Enum e){
        if(enumMapper.insert(e) > 0){
            return ServerResponse.createBySuccessMessage("操作成功");
        }
        return ServerResponse.createByErrorMessage("操作失败");
    }


    @SysLog("删除枚举")
    public ServerResponse<String> del(Integer id){
        if(enumMapper.deleteByPrimaryKey(id) > 0){
            return ServerResponse.createBySuccessMessage("操作成功");
        }
        return ServerResponse.createByErrorMessage("操作失败");
    }

    @SysLog("更新枚举")
    public ServerResponse<String> update(Enum e){
        if(enumMapper.updateByPrimaryKey(e) > 0){
            return ServerResponse.createBySuccessMessage("操作成功");
        }
        return ServerResponse.createByErrorMessage("操作失败");
    }

}
